@include('admin.layout.bone_header')

<div class="layui-btn-container">

{{--    <button class="layui-btn" data-type="addImages">添加商品</button>--}}

</div>


<table class="layui-hide" id="think-table" lay-filter="think-table"></table>

<script type="text/html" id="barDemo">
        @{{# if(d['order_info']['status'] == 2 && d['status'] == 0){ }}
            <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="send_huo">发货</a>
        @{{# } }}

</script>

<script>

    layui.use('table', function () {
        let table = layui.table;
        UI.getPageTable(table, "{{route('admin.orders.orders')}}", [
            {field: 'order_child_id', title: 'ID', width: 80, sort: true, fixed: 'left'}
            , {field: 'order_code', title: ' 订单号'}
            , {field: 'price', title: '商品名称',templet:function (d) {
                    let jsonArr = JSON.parse(d['json_data']);
                    return jsonArr['project_name']
                }}
            , {field: 'price', title: '商品价格'}
            , {field: 'nums', title: '商品数量'}
            , {field: 'nums', title: '供货商ID',templet:function (d){
                return d['project_info']['shop_id'];
                }}
            , {field: 'status', title: '订单类型',templet:function (d){
                    let arr = ['普通订单','专卖订单','会员订单'];
                    return arr[d['type']];
                }}
            , {field: 'status', title: '地址',templet:function (d){
                    let jsonArr = JSON.parse(d['user_info']['json_city_address']);
                    return jsonArr['real_name']+'-'+jsonArr['phone']+'-'+jsonArr['address']
                }}
            , {field: 'status', title: '显示状态',templet:function (d){
                    if(d['order_info']['status'] == 0){
                        return '未支付';
                    }
                    let arr = ['未发货','','未发货','已发货','已完成'];
                    return arr[d['status']];
                }}
            ,{fixed: 'right',title:'操作', align:'center', toolbar: '#barDemo'}
        ]);

        table.on('tool(think-table)', function (obj) {
            let data = obj.data;
            if(obj.event == 'send_huo'){
                UI.openLayer("{{route('admin.orders.send_huo')}}?order_child_id="+data['order_child_id']);
            }
        });
        let $ = layui.$, active = {

        };
        $('.layui-btn-container .layui-btn').on('click', function () {
            let type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        $('.search .layui-btn').on('click', function () {
            let type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    })


</script>


@include('admin.layout.bone_footer')
